package top.tanglizhi.springboot3.controller.test;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tanglizhi.springboot3.base.PageInfo;
import top.tanglizhi.springboot3.base.PageResult;
import top.tanglizhi.springboot3.base.R;

@RestController
@RequestMapping("/test/result")
public class ResultTestController {

    @GetMapping("/ok")
    public R<PageResult<String>> ok() {
        PageInfo page = new PageInfo();
        page.setPn(1);
        page.setPs(10);
        PageResult<String> result = new PageResult<>();
        result.setPage(page);
        return R.ok(result);
    }

    @GetMapping("/fail")
    public R<PageResult<String>> fail(String message) {
        message = StringUtils.hasText(message) ? message : "程序错误";
        return R.fail(message,null);
    }
}
